class VerificationCodeTimer {
	seconds = 0
	timer$: any
	constructor() {
		this.seconds = 0
		this.timer$ = null
	}

	start(seconds = 60) {
		this.seconds = seconds
		this.timer$ = setInterval(() => {
			if (this.seconds > 0) {
				this.seconds = this.seconds - 1
			} else {
				this.clear()
			}
		}, 1000)
	}
	clear() {
		this.seconds = 0
		clearInterval(this.timer$)
		this.timer$ = null
	}
}

const verificationCode = reactive(new VerificationCodeTimer())
export { verificationCode }
